package cn.yunhe.servlet.FboardSboard;

import cn.yunhe.entity.Fboard;
import cn.yunhe.entity.Sboard;
import cn.yunhe.service.FboardService;
import cn.yunhe.service.SboardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/secondBoardListServlet")
public class secondBoardListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        SboardService sboardService=new SboardService();
        FboardService fboardService=new FboardService();
        //获取所有一级版块
        List<Fboard>fboardList=fboardService.fboardListByFbflag(0);
        System.out.println("<===fboardList.size()====>"+fboardList.size());
        request.setAttribute("fboardList",fboardList);
        //获取所有二级版块
        List<Sboard>sboardList=sboardService.findSboardBySbflag(0);
        System.out.println("===========secondBoardListServlet start================");
        System.out.println("<===sboardList=====>"+sboardList);
        System.out.println("<===sboardList.size()=====>"+sboardList.size());
        System.out.println("===========secondBoardListServlet end================");
        request.setAttribute("sboardList",sboardList);

        //重定向
        request.getRequestDispatcher("manage/productClass.jsp").forward(request,response);

    }
}
